home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / UndoableEdit.java < prev    next >
Text File  |  1998-06-30  |  4KB  |  128 lines

  1. /*
  2.  * @(#)UndoableEdit.java    1.10 98/02/05
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.undo;
  22.  
  23. import com.sun.java.swing.event.*;
  24.  
  25. /**
  26.  * An object representing an edit that has been done, and that can be
  27.  * undone and redone
  28.  *
  29.  * @version 1.10, 02/05/98
  30.  * @author Ray Ryan
  31.  */
  32.  
  33. public interface UndoableEdit {
  34.     /**
  35.      * Undo the edit that was made.
  36.      */
  37.     public void undo() throws CannotUndoException;
  38.  
  39.     /**
  40.      * True if it is still possible to undo this operation
  41.      */
  42.     public boolean canUndo();
  43.  
  44.     /**
  45.      * Re-apply the edit, assuming that it has been undone.
  46.      */
  47.     public void redo() throws CannotRedoException;
  48.  
  49.     /**
  50.      * True if it is still possible to redo this operation
  51.      */
  52.     public boolean canRedo();
  53.  
  54.     /**
  55.      * May be sent to inform an edit that it should no longer be
  56.      * used. This is a useful hook for cleaning up state no longer
  57.      * needed once undoing or redoing is impossible--for example,
  58.      * deleting file resources used by objects that can no longer be
  59.      * undeleted. UndoManager calls this before it dequeues edits.
  60.      *
  61.      * Note that this is a one-way operation. There is no "undie"
  62.      * method.
  63.      *
  64.      * @see CompoundEdit#die
  65.      */
  66.     public void die();
  67.  
  68.     /**
  69.      * This UndoableEdit should absorb anEdit if it can. Return true
  70.      * if anEdit has been incoporated, false if it has not.
  71.      *
  72.      * <p>Typically the receiver is already in the queue of a
  73.      * UndoManager (or other UndoableEditListener), and is being
  74.      * given a chance to incorporate anEdit rather than letting it be
  75.      * added to the queue in turn.</p>
  76.      *
  77.      * <p>If true is returned, from now on anEdit must return false from
  78.      * canUndo() and canRedo(), and must throw the appropriate
  79.      * exception on undo() or redo().</p>
  80.      */
  81.     public boolean addEdit(UndoableEdit anEdit);
  82.  
  83.     /**
  84.      * Return true if this UndoableEdit should replace anEdit. The
  85.      * receiver should incorporate anEdit's state before returning true.
  86.      *
  87.      * <p>This message is the opposite of addEdit--anEdit has typically
  88.      * already been queued in a UndoManager (or other
  89.      * UndoableEditListener), and the receiver is being given a chance
  90.      * to take its place.</p>
  91.      *
  92.      * <p>If true is returned, from now on anEdit must return false from
  93.      * canUndo() and canRedo(), and must throw the appropriate
  94.      * exception on undo() or redo().</p>
  95.      */
  96.     public boolean replaceEdit(UndoableEdit anEdit);
  97.  
  98.     /**
  99.      * Return false if this edit is insignificant--for example one
  100.      * that maintains the user's selection, but does not change any
  101.      * model state. This status can be used by an UndoableEditListener
  102.      * (like UndoManager) when deciding which UndoableEdits to present
  103.      * to the user as Undo/Redo options, and which to perform as side
  104.      * effects of undoing or redoing other events.
  105.      */
  106.     public boolean isSignificant();
  107.  
  108.     /**
  109.      * Provide a localized, human readable description of this edit
  110.      * suitable for use in, say, a change log.
  111.      */
  112.     public String getPresentationName();
  113.  
  114.     /**
  115.      * Provide a localized, human readable description of the undoable
  116.      * form of this edit, e.g. for use as an Undo menu item. Typically
  117.      * derived from getDescription();
  118.      */
  119.     public String getUndoPresentationName();
  120.  
  121.     /**
  122.      * Provide a localized, human readable description of the redoable
  123.      * form of this edit, e.g. for use as a Redo menu item. Typically
  124.      * derived from getPresentationName();
  125.      */
  126.     public String getRedoPresentationName();
  127. }
  128.